package com.qingzhuge.member.entity;

import com.qingzhuge.entity.BasePkLongEntity;
import com.qingzhuge.member.enums.EnumThirdOauthType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;

/**
 * @author : zero.xiao
 * @description :第三方登录
 * 例如QQ登录，默认在user表中插入一条记录，register_type为QQ，u_qq_key为第三方QQ登录生成的唯一标识，
 * 同时在thirdlogin表中插入一条记录，userid为user表生成帐号的userid，third_key为第三方登录的唯一标识，
 * 其他第三方登录帐号类似。
 * 首次注册手机帐号：
 * 在user表中插入一条记录，register_type为手机，thirdlogin表不用操作
 * @date : 2018/8/7 0007 下午 15:47
 * @modified :
 * @since :
 */
@EqualsAndHashCode(callSuper = true)
@Setter
@Getter
@Entity
@Table(name = "sys_member_third_oauth")
public class SysMemberThirdPartyAuth extends BasePkLongEntity {
    private static final long serialVersionUID = -8622105543303280539L;
    public final static String SYS_MEMBER_THIRDPARTY_AUTH = "Sys_Member_ThirdParty_Auth";
    /**
     * 用户帐号id
     */
    private Long userId;
    /**用户账号*/
    private String account;
    /**
     * 三方应用类型
     */
    private EnumThirdOauthType type;
    /**授权用户唯一标识*/
    @Column(unique = true)
    private String openId;
    /**用户认证*/
    private String token;
    private String unionId;
    private String nickName;
    /**用户性别*/
    private Long gender;
    private String language;
    private String city;
    private String province;
    private String country;
    /**用户头像地址*/
    private String avatarUrl;
    /**用户类型*/
    private String provider;
    @Transient
    private Watermark watermark;

    @Data
    private static class Watermark implements Serializable {
        private static final long serialVersionUID = 8100916613865916899L;
        private String timestamp;
        private String appid;
    }
}
